home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Applications / QuArK / plugins / mapheapstatus.py < prev    next >
Text File  |  2004-01-05  |  5KB  |  147 lines

  1.  
  2. #$Header: /cvsroot/quark/runtime/plugins/mapheapstatus.py,v 1.2 2002/02/26 06:33:59 tiglari Exp $
  3.  
  4. import quarkx
  5. import quarkpy.mapmenus
  6. import quarkpy.mapcommands
  7. import quarkpy.dlgclasses
  8. from quarkpy.maputils import *
  9.  
  10.  
  11. #Field   Meaning
  12. #
  13. #TotalAddrSpace    The (current) total address space available to your program,
  14. #                   in bytes. This will grow as your program's dynamic memory
  15. #                   usage grows.
  16. #TotalUncommitted  The total number of bytes (of TotalAddrSpace) for which
  17. #                   space has not been allocated in the swap file. 
  18. #TotalCommitted    The total number of bytes (of TotalAddrSpace) for which
  19. #                   space has been allocated in the swap file.
  20. #                   Note:TotalUncommitted + TotalCommitted = TotalAddrSpace
  21. #TotalAllocated    The total number of bytes dynamically allocated by your program.
  22. #
  23. #TotalFree         The total number of free bytes available in the (current)
  24. #                   address space for allocation by your program. If this number
  25. #                   is exceeded, and enough virtual memory is available, more
  26. #                   address space will be allocated from the OS; TotalAddrSpace
  27. #                   will be incremented accordingly.
  28. #FreeSmall         Total bytes of small memory blocks which are not currently
  29. #                   allocated by your program. 
  30. #FreeBig           Total bytes of big memory blocks which are not currently
  31. #                   allocated by your program. Large free blocks can be
  32. #                   created by coalescing smaller, contiguous, free blocks
  33. #                   or by freeing a large dynamic allocation.  (The exact
  34. #                   size of the blocks is immaterial)
  35. #Unused            Total bytes which have never been allocated by your program.
  36. #                   Note: Unused + FreeBig + FreeSmall = TotalFree
  37. #                   These three fields (Unused, FreeBig, and FreeSmall) refer
  38. #                   to dynamic allocation by the user program.
  39. #Overhead          The total number of bytes required by the heap manager to
  40. #                   manage all the blocks dynamically allocated by your program. 
  41. #HeapErrorCode     Indicates the current status of the heap, as internally
  42. #                   determined.
  43.  
  44. #Note:   TotalAddrSpace, TotalUncommitted and TotalCommitted refer to OS memory used by the program, where as TotalAllocated and TotalFree refer to the heap memory used within the program by dynamic allocations. Therefore, to monitor dynamic memory used in your program use TotalAllocated and TotalFree.
  45.  
  46. class HeapStatus(quarkpy.dlgclasses.placepersistent_dialogbox):
  47.     #
  48.     # dialog layout
  49.     #
  50.  
  51.     endcolor = AQUA
  52.     size = (250,120)
  53.     dfsep = 0.50
  54.     flags = FWF_KEEPFOCUS
  55.     
  56.     dlgdef = """
  57.         {
  58.         Style = "9"
  59.         Caption = "Heap Status Dialog"
  60.  
  61.         TotalAllocated: =
  62.         {
  63.         Txt = "&"
  64.         Typ = "ESR"
  65.         Hint = "Total Bytes Allocated by the Program"
  66.         }
  67.  
  68.         ChangeAllocated: =
  69.         {
  70.         Txt = "&"
  71.         Typ = "ESR"
  72.         Hint = "Change in Total Bytes Allocated by the Program"
  73.         }
  74.  
  75.         
  76.  
  77.         sep: = { Typ="S" Txt=" " }
  78.  
  79.         cancel:py = {Txt="" }
  80.     }
  81.     """
  82.  
  83.     #
  84.     # __init__ initialize the object
  85.     #
  86.  
  87.     def __init__(self, form, editor, src):
  88.  
  89.     #
  90.     # General initialization of some local values
  91.     #
  92.  
  93.         self.editor = editor
  94.         #
  95.         # heapstatus object passed as parameter used directly to load
  96.         #   dialog
  97.         #
  98.         self.src = src
  99.         totalalloc=eval(src["TotalAllocated"])
  100.         try:
  101.             oldalloc = editor.oldalloc
  102.             src["ChangeAllocated"]=`totalalloc-oldalloc`
  103.         except:
  104.             pass
  105.         editor.oldalloc = totalalloc
  106.         self.form = form
  107.           
  108.     #
  109.     # Create the dialog form and the buttons
  110.     #
  111.  
  112.         quarkpy.dlgclasses.placepersistent_dialogbox.__init__(self, form, src, "heapstatus",
  113.         cancel = quarkpy.qtoolbar.button(
  114.             self.cancel,
  115.             "Close",
  116.             ico_editor, 0,
  117.             "Cancel"))
  118.  
  119.     def cancel(self, dlg):
  120.         self.src = None 
  121.         qmacro.dialogbox.close(self, dlg)
  122.  
  123.  
  124. def HeapStatusClick(m):
  125.     status = quarkx.heapstatus()
  126.     HeapStatus(quarkx.clickform,mapeditor(),status)
  127.  
  128.  
  129. menheapstatus = qmenu.item("HeapStatus",HeapStatusClick,"Heap Status")
  130.  
  131. if quarkx.setupsubset(SS_MAP, "Options")["Developer"]:
  132.   quarkpy.mapcommands.items.append(menheapstatus)
  133.  
  134.  
  135. # ----------- REVISION HISTORY ------------
  136. #
  137. #
  138. # $Log: mapheapstatus.py,v $
  139. # Revision 1.2  2002/02/26 06:33:59  tiglari
  140. # now tracks changes in memory used
  141. #
  142. # Revision 1.1  2002/01/08 10:11:41  tiglari
  143. # uses heapstatus function to display heap info (currently just TotalAllocated,
  144. # all of the fields mentioned in the comments can be accessed as specifics
  145. # of the QObject returned by heapstatus)
  146. #
  147.